package action;

import java.awt.Toolkit;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;




public class ActionConnect extends Action {

	
	private DatagramSocket socket;
	private ActionMove actionMove;
	private  int dpi;
	private int destinationPort;
	



	public ActionConnect(DatagramSocket socket,ActionMove actionMove){

		this.actionMove = actionMove;
		this.socket = socket;
	}
	
	@Override
	public void execute(Object object) {
		float dpiRatio = java.awt.Toolkit.getDefaultToolkit().getScreenResolution() / dpi;
		actionMove.setDpiRatio(dpiRatio);
		String mexToSmarthphone = "OK";
		byte[] data=mexToSmarthphone.getBytes();
		DatagramPacket packet=new DatagramPacket(data,data.length,(InetAddress)object,destinationPort);
		try {
			socket.send(packet);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public double getDpi() {
		return dpi;
	}

	public void setDpi(int dpi) {
		this.dpi = dpi;
	}
	
	public int getDestinationPort() {
		return destinationPort;
	}

	public void setDestinationPort(int destinationPort) {
		this.destinationPort = destinationPort;
	}

}
